package com.material.operation.controllers;

import com.material.operation.bean.User;
import com.material.operation.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author : hongwei.zhang
 * @className : operation - UserController
 * @description : 用户控制器
 * @date : 2020-11-16 20:35
 */
@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("login")
    public String login(HttpServletRequest request,String userName, String password, int type){
        User user = new User(userName,password,type);
        boolean flag = userService.checkUser(user);
        if(flag){
            return "index";
        }else{
            request.setAttribute("msg","用户名密码错误！");
            return "login";
        }

    }
}
